package com.yu.controller;


import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.yu.model.Result;
import com.yu.model.dto.DoctorPageDTO;
import com.yu.model.dto.AdminDTO;
import com.yu.model.dto.PatientPageDTO;
import com.yu.model.entity.Doctor;
import com.yu.model.entity.Patient;
import com.yu.service.AdminService;
import com.yu.service.DoctorService;
import com.yu.service.PatientService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

@Slf4j
@RestController
@Api(tags = "管理员相关接口")
@RequestMapping("/admin")
public class AdminController {



    @Resource
    private AdminService adminService;
    @Resource
    private DoctorService doctorService;

    @Resource
    private PatientService patientService;


    @PostMapping("/login")
    @ApiOperation(value = "管理员登录")
    public Result<String> login(AdminDTO adminDTO){
        return adminService.login(adminDTO);
    }


    @GetMapping("/page/doctor")
    @ApiOperation(value = "分页查询医生")
    public Result<Page<Doctor>> pageList(DoctorPageDTO doctorPageDTO){
        return Result.success(doctorService.pageList(doctorPageDTO));
    }



    @GetMapping("/page/patient")
    @ApiOperation(value = "分页查询病人")
    public Result<Page<Patient>> pageList(PatientPageDTO patientPageDTO){
        return Result.success(patientService.pageList(patientPageDTO));
    }


}
